package com.ruoyi.flink.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.flink.domain.UdfConfig;
import com.ruoyi.flink.service.IUdfConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * udf函数管理Controller
 * 
 * @author shu_k
 * @date 2021-04-23
 */
@RestController
@RequestMapping("/flink/UdfConfig")
public class UdfConfigController extends BaseController
{
    @Autowired
    private IUdfConfigService udfConfigService;

    /**
     * 查询udf函数管理列表
     */
    @PreAuthorize("@ss.hasPermi('flink:UdfConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(UdfConfig udfConfig)
    {
        startPage();
        List<UdfConfig> list = udfConfigService.selectUdfConfigList(udfConfig);
        return getDataTable(list);
    }

    /**
     * 导出udf函数管理列表
     */
    @PreAuthorize("@ss.hasPermi('flink:UdfConfig:export')")
    @Log(title = "udf函数管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(UdfConfig udfConfig)
    {
        List<UdfConfig> list = udfConfigService.selectUdfConfigList(udfConfig);
        ExcelUtil<UdfConfig> util = new ExcelUtil<UdfConfig>(UdfConfig.class);
        return util.exportExcel(list, "udf函数管理数据");
    }

    /**
     * 获取udf函数管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('flink:UdfConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(udfConfigService.selectUdfConfigById(id));
    }

    /**
     * 新增udf函数管理
     */
    @PreAuthorize("@ss.hasPermi('flink:UdfConfig:add')")
    @Log(title = "udf函数管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UdfConfig udfConfig)
    {
        return toAjax(udfConfigService.insertUdfConfig(udfConfig));
    }

    /**
     * 修改udf函数管理
     */
    @PreAuthorize("@ss.hasPermi('flink:UdfConfig:edit')")
    @Log(title = "udf函数管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UdfConfig udfConfig)
    {
        return toAjax(udfConfigService.updateUdfConfig(udfConfig));
    }

    /**
     * 删除udf函数管理
     */
    @PreAuthorize("@ss.hasPermi('flink:UdfConfig:remove')")
    @Log(title = "udf函数管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(udfConfigService.deleteUdfConfigByIds(ids));
    }
}
